package com.yueqian.framework.config;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitDelayConfig {    //声明延时交换机
	@Bean
	public DirectExchange delayExchange() {
		return ExchangeBuilder.directExchange("delay.direct.exchange")
					   .delayed()
					   .build();
	}

	//声明队列
	@Bean
	public Queue delayQueue() {
		return QueueBuilder.durable("delay.queue").build();
	}

	//声明绑定关系
	@Bean
	public Binding delayBinding(Queue delayQueue, DirectExchange delayExchange) {
		return BindingBuilder.bind(delayQueue).to(delayExchange).with("delay");
	}

}
